package crawler.server.dispatch.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/crawler/server")
public class ServerController {
	
	@GetMapping(value = "/search/{searchType}")
    public String search(HttpServletRequest request, HttpServletResponse response,
    		@PathVariable(value = "searchType") String searchType,
			@RequestParam(value = "pageNo", required = false,defaultValue= "1") int pageNo,
			@RequestParam(value = "pageSize", required = false,defaultValue= "20") int pageSize) { 
		
        return "search";  
    } 
	
    
	@GetMapping(value = "/task/{taskId}")
    public String getTask(HttpServletRequest request, HttpServletResponse response,
    		@PathVariable(value = "taskId") String taskId) { 
		
        return "getTask";  
    } 
	
	@PostMapping(value = "/task")
    public String createTask(HttpServletRequest request, HttpServletResponse response) {  
        return "createTask";  
    } 
	
	@PutMapping(value = "/task/{taskId}")
	public String updateTask(HttpServletRequest request, HttpServletResponse response,
			@PathVariable(value = "taskId") String taskId) {
		
		
		return "updateTask";
	}
	
	
	@GetMapping(value = "/account/{accountId}")
    public String getAccount(HttpServletRequest request, HttpServletResponse response,
    		@PathVariable(value = "accountId") String accountId) { 
		
		
        return "getAccount";  
    } 
	
	@PostMapping(value = "/account")
    public String createAccount(HttpServletRequest request, HttpServletResponse response) {  
        return "createAccount";  
    } 
	
	@PutMapping(value = "/account/{accountId}")
	public String updateAccount(HttpServletRequest request, HttpServletResponse response,
			@PathVariable(value = "accountId") String accountId) {
		
		
		return "updateTask";
	}
    
	@GetMapping(value = "/proxy/{proxyId}")
    public String getProxy(HttpServletRequest request, HttpServletResponse response,
    		@PathVariable(value = "proxyId") String proxyId) { 
		
		
        return "getProxy";  
    } 
	
	@PostMapping(value = "/proxy")
    public String createProxy(HttpServletRequest request, HttpServletResponse response) {  
		
        return "createProxy";  
    } 
	
	@PutMapping(value = "/proxy/{proxyId}")
	public String updateProxy(HttpServletRequest request, HttpServletResponse response,
			@PathVariable(value = "proxyId") String proxyId) {
		
		
		return "updateProxy";
	}

}
